﻿package coreFx{
	import flash.display.MovieClip;
	import flash.display.Stage;
	import flash.events.Event;
	
	import flash.utils.Timer;
	import flash.events.TimerEvent;
	
	
	public class Staff extends MovieClip{
		
		//Attrib
		var belongTo:String ;
		var id:Number;
		
		var nextTarget:String;
		var delayx:Number;
		var InQueue:Array;
		var triggerx:Timer;
		
		
		public function Staff(belong:String,nextTg:String,dl:Number,xpos:Number,ypos:Number){
			this.belongTo = belong;
			this.nextTarget = nextTg;
			this.delayx = dl;
			this.InQueue = new Array();
			this.x = xpos; 
			this.y = ypos+20;
			trace('initiate '+this.x);
			
		}
		
		
		public function _push(cus:Customer){
			cus.x = this.x;
			cus.serve();
			this.InQueue.push(cus);
			
			triggerx = new Timer(this.delayx,1);
			triggerx.start();
			triggerx.addEventListener(TimerEvent.TIMER,_release);
			
		}
		
		public function _release(e:TimerEvent){
			//InQueue[0].target = this.nextTarget;
			var road:String = this.InQueue[0].shiftRoadMap();
			trace('man next target-->'+road);
			InQueue[0].target = road;
			InQueue[0].y = this.y+20;
			InQueue.splice(0,1);
			
			triggerx.addEventListener(TimerEvent.TIMER,_release);
		}
		
		public function _pop(){
			
		}
	
		
		
		
		
	}
}